/*
 * @Description: 全宗表格组件
 * @Author: Rfan
 * @Date: 2022-01-07 15:20:55
 * @LastEditTime: 2022-09-08 14:35:58
 */

import { useEffect, useState } from 'react';
import { useMetadataBusinessContext } from '../contexts/MetadataBusinessContext';
import MetadataPane from './MetadataPane';
import type { ICoordinate } from '@/interfaces/global';

const List = () => {
  const { selectAT, selectLevel } = useMetadataBusinessContext();

  // 请求参数（坐标）
  const [query, setQuery] = useState<ICoordinate>(null);

  useEffect(() => {
    if (selectAT?.atType && (selectLevel?.level || selectLevel?.level === 0)) {
      setQuery({
        atType: selectAT.atType,
        atCode: selectAT.atCode,
        level: selectLevel.level
      });
    }
  }, [selectAT, selectLevel]);

  return (
    <MetadataPane
      title={selectLevel?.levelName ? `${selectAT?.atName}-${selectLevel?.levelName} ` : ''}
      data={query}
    />
  );
};

export default List;
